<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
Route::get('news/index/{tid?}', 'NewsController@index')
    ->where(['tid' => '\d+']);
Route::get('news/details/{id?}', 'NewsController@detail')
    ->where(['id' => '\d+']);
Route::post('news/doComment', 'NewsController@doComment');
//传值约束：
//Route::get()->where(["传值名称"=>"正则表达式"])
//可选传值，在名称后面加 问号
//后台的路由
Route::get('admin/login','admin\UserController@login');
Route::post("admin/dologin", "admin\UserController@dologin");

Route::group(['prefix' => 'admin', 'namespace' => 'admin','middleware'=>'check'], function () {
    Route::get("/", "IndexController@index");
    Route::get("news/add", "NewsController@add");
    Route::get("news/index", "NewsController@index");
    Route::get("news/edit", "NewsController@edit");
    Route::post("news/doadd", "NewsController@doadd");
    Route::get("category/add", "CategoryController@add");
    Route::get("loginout", "UserController@loginout");
    Route::post('category/doadd','CategoryController@doadd');
    Route::get('category/index',"CategoryController@index");
    Route::get('category/del/{id}',"CategoryController@del");
    Route::get('category/edit/{id}',"CategoryController@edit");
    Route::post('category/doedit',"CategoryController@doedit");
});